package Pattern.FactoryPattern.workTest.Work.Program4;

class Nvwa {
    public static Person createPeople(String peo) {
        Person person = null;
        switch (peo) {
            case "M":
                person = new Man();
                break;
            case "W":
                person = new Woman();
                break;
            case "R":
                person = new Robot();
                break;
        }
        return person;
    }
}

abstract class Person {
    public abstract void create();
}

class Man extends Person {

    @Override
    public void create() {
        System.out.println("女娲造了一个男人。");
    }
}

class Woman extends Person {

    @Override
    public void create() {
        System.out.println("女娲造了一个女人。");
    }
}

class Robot extends Person {

    @Override
    public void create() {
        System.out.println("女娲造了一个机器人。");
    }
}

public class Test {
    public static void main(String[] args) {
        Person person = Nvwa.createPeople("M");
        person.create();
    }
}
